﻿using System.Windows.Input;
using JulMar.Silverlight.Mvvm;
using MediaBrowserSL.RIA.MvvmUtils;
using MediaBrowserSL.RIA.Services;

namespace MediaBrowserSL.RIA.ViewModels
{
    /// <summary>
    /// Home View Model
    /// </summary>
    public class PageHomeViewModel : PageViewModelBase
    {
        #region Private Member
        private PageMoviesViewModel pageMoviesViewModel;
        private PagePicturesViewModel pagePicturesViewModel;
        private PageBooksViewModel pageBooksViewModel;
        private PageMusicViewModel pageMusicViewModel;
        #endregion

        #region Public Properties
        public override string Name
        {
            get { return "Page Home"; }
        }
        #endregion

        #region Command

        public ICommand MoviesViewCommand
        {
            get;
            private set;
        }

        public ICommand PicturesViewCommand
        {
            get;
            private set;
        }

        public ICommand BooksViewCommand
        {
            get;
            private set;
        }

        public ICommand MusicsViewCommand
        {
            get;
            private set;
        }
        #endregion

        public PageHomeViewModel(IMediaRiaServices service,
                                 PageMoviesViewModel pageMoviesViewModel,
                                 PagePicturesViewModel pagePicturesViewModel,
                                 PageBooksViewModel pageBooksViewModel,
                                 PageMusicViewModel pageMusicViewModel)
            : base(service)
        {
            this.pageMoviesViewModel = pageMoviesViewModel;
            this.pagePicturesViewModel = pagePicturesViewModel;
            this.pageBooksViewModel = pageBooksViewModel;
            this.pageMusicViewModel = pageMusicViewModel;
            MoviesViewCommand = new DelegatingCommand(NavigateToMoviesView);
            PicturesViewCommand = new DelegatingCommand(NavigateToPicturesView);
            BooksViewCommand = new DelegatingCommand(NavigateToBooksView);
            MusicsViewCommand = new DelegatingCommand(NavigateToMusicsView);
        }

        /// <summary>
        /// Navigate to Movies View
        /// </summary>
        private void NavigateToMoviesView()
        {
            SendMessage(MediatorMessages.UpdateCurrentView, pageMoviesViewModel);
        }

        /// <summary>
        /// Navigate to Pictures View
        /// </summary>
        private void NavigateToPicturesView()
        {
            SendMessage(MediatorMessages.UpdateCurrentView, pagePicturesViewModel);
        }

        /// <summary>
        /// Navigate to Books View
        /// </summary>
        private void NavigateToBooksView()
        {
            SendMessage(MediatorMessages.UpdateCurrentView, pageBooksViewModel);
        }

        /// <summary>
        /// Navigate to Musics View
        /// </summary>
        private void NavigateToMusicsView()
        {
            SendMessage(MediatorMessages.UpdateCurrentView, pageMusicViewModel);
        }

    }
}
